package com.pengji.rcp.plugin.view;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;

public class URLReader {
	public static void main(String[] args) {
		URL url = null;
		BufferedWriter out = null;
		String inputLine = null;
		BufferedReader in = null;
		try {
			url = new URL("http://www.qq.com");
			File writeFile = new File("d:\\baidu.html");
			try {
				in = new BufferedReader(new InputStreamReader(url.openStream()));
			} catch (IOException e2) {
				// TODO Auto-generated catch block
				e2.printStackTrace();
			}
			try {
				out = new BufferedWriter(new FileWriter(writeFile));
			} catch (IOException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
			try {
				while ((inputLine = in.readLine()) != null) {
					out.write(inputLine);
				}

				out.flush();
				in.close();
				out.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}

		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
